package com.hsjk.szwj.module.pay.controller.app.refund.vo;

import com.hsjk.szwj.module.pay.dal.dataobject.config.AbstractResp;
import com.hsjk.szwj.module.pay.dal.dataobject.order.RefundOrderDO;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/08/25 01:13
 **/
@Data
public class QueryRefundOrderRespVO extends AbstractResp {
    /**
     * 退款订单号（支付系统生成订单号）
     */
    private Long refundOrderId;

    /**
     * 支付订单号（与t_pay_order对应）
     */
    private Long payOrderId;

    /**
     * 商户号
     */
    private Long mchId;

    /**
     * 应用ID
     */
    private Long appId;

    /**
     * 商户退款单号（商户系统的订单号）
     */
    private String mchRefundNo;

    /**
     * 支付金额,单位分
     */
    private Long payAmount;

    /**
     * 退款金额,单位分
     */
    private Long refundAmount;

    /**
     * 三位货币代码,人民币:cny
     */
    private String currency;

    /**
     * 退款状态:0-订单生成,1-退款中,2-退款成功,3-退款失败
     */
    private Integer state;

    /**
     * 渠道订单号
     */
    private String channelOrderNo;

    /**
     * 渠道错误码
     */
    private String errCode;

    /**
     * 渠道错误描述
     */
    private String errMsg;

    /**
     * 扩展参数
     */
    private String extParam;

    /**
     * 订单退款成功时间
     */
    private LocalDateTime successTime;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;


    public static QueryRefundOrderRespVO buildByRefundOrder(RefundOrderDO refundOrder) {

        if (refundOrder == null) {
            return null;
        }

        QueryRefundOrderRespVO result = new QueryRefundOrderRespVO();
        BeanUtils.copyProperties(refundOrder, result);
        result.setSuccessTime(refundOrder.getSuccessTime() == null
                ? null : refundOrder.getSuccessTime());
        result.setCreateTime(refundOrder.getCreateTime() == null
                ? null : refundOrder.getCreateTime());
        return result;
    }
}
